﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using Quartz;
using Quartz.Impl;
using Quartz.Simpl;
using Quartz.Xml;

namespace ConsoleApplication1._03_Service
{
    public class QuartzSchedulerService
    {
        public static IScheduler Scheduler { get; private set; }

        public static void Init()
        {
            XMLSchedulingDataProcessor processor = new XMLSchedulingDataProcessor(new SimpleTypeLoadHelper());
            ISchedulerFactory sf = new StdSchedulerFactory();
            Scheduler = sf.GetScheduler().Result;
            processor.ProcessFileAndScheduleJobs("~/quartz_jobs.xml", Scheduler);
        }

        public static void Start()
        {
            Scheduler.Start();
        }

        public static void Stop()
        {
            Scheduler.Shutdown();
        }
    }
}
